home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / tool-inc.zip / GETFILE3.INC < prev    next >
Text File  |  1989-07-10  |  2KB  |  86 lines

  1.  
  2. (*
  3.  * Copyright 1987, 1989 Samuel H. Smith;  All rights reserved
  4.  *
  5.  * This is a component of the ProDoor System.
  6.  * Do not distribute modified versions without my permission.
  7.  * Do not remove or alter this notice or any other copyright notice.
  8.  * If you use this in your own program you must distribute source code.
  9.  * Do not use any of this in a commercial product.
  10.  *
  11.  *)
  12.  
  13. (*
  14.  * getfile2 - file list processing library (simplified version)
  15.  *
  16.  * This module will change a wildcard list of files into a
  17.  * sorted file name list.
  18.  *
  19.  * Samuel H. Smith, rev. 25-oct-87
  20.  *
  21.  *)
  22.  
  23. procedure getfiles (pattern:       string65;
  24.                     var fdir:      filearray;
  25.                     var num:       integer);
  26. var
  27.    i:             integer;
  28.    curdir:        string65;
  29.    keyword:       string13;
  30.    doscan:        boolean;    {can dos do this wildcard?}
  31.    DirInfo:       SearchRec;
  32.  
  33. begin
  34.    stoupper(pattern);
  35.  
  36.    curdir := path_only(pattern);
  37.    if curdir = '' then
  38.       curdir := '@:';
  39.  
  40.    if (length(curdir) = 2) and (curdir[2] = ':') then
  41.       getdir(ord(curdir[1])-ord('@'),curdir);
  42.  
  43.    if (curdir[length(curdir)] <> '\') then
  44.    begin
  45.       inc(curdir[0]);
  46.       curdir[length(curdir)] := '\';
  47.    end;
  48.  
  49.    keyword := remove_path(pattern);
  50.  
  51.    doscan := true;
  52.    i := pos('*',keyword);
  53.    if i > 0 then
  54.       if (keyword[i+1] <> '.') and (i < length(keyword)) then
  55.          doscan := false;
  56.  
  57.    if doscan = false then
  58.       pattern := curdir + '*.*';
  59.  
  60.    num := 0;
  61.    FindFirst(pattern,$21,DirInfo);
  62.  
  63.    while (DosError = 0) and (num < maxnumfiles) do
  64.    begin
  65.          {best if $B-}
  66.       if doscan or wildcard_match(keyword, DirInfo.name) then
  67.       begin
  68.          inc(num);
  69.          savestr(fdir[num],curdir + DirInfo.name);
  70.       end;
  71.  
  72.       FindNext(DirInfo);
  73.    end;
  74.  
  75. {  if num >= maxnumfiles then
  76.       writeln('Warning:  Files in excess of ', maxnumfiles, ' ignored.');
  77. }
  78. {writeln('getfile3 par=',pattern,
  79.                  ' cd=',curdir,
  80.                 ' key=',keyword,
  81.                 ' can=',doscan,
  82.                 ' n=',num);}
  83.  
  84. end;                     {getfiles}
  85.  
  86.